package com.haiyou.common.util;

import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @Author: xlight
 */
public class GameTime {

    static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    public static long nowMillis(){
        return Instant.now().toEpochMilli();
    }

    public static long nowSecond(){
        return Instant.now().getEpochSecond();
    }

    public static Date nowDate(){
        return Date.from(Instant.now());
    }

    public static String formatMillis(long millis){
        Instant instant = Instant.ofEpochMilli(millis);
        return instant.atZone(ZoneId.systemDefault()).format(formatter);
    }
}
